package com.own.compoent.mq.rabbit.consumer.receiver;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * CustomReceiver
 *
 * @author chenxueli
 * @date 2023-07-24 20:25:00
 */
@Slf4j
@Component
public class CustomReceiver {

    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(),
                    exchange = @Exchange(value = "fanout.exchange", type = ExchangeTypes.FANOUT)
            )
    )
    public void process(String payload) {
        log.info("刷新广播消息receive:{}", payload);
    }

    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(),
                    exchange = @Exchange(value = "fanout.exchange", type = ExchangeTypes.FANOUT)
            )
    )
    public void process2(String payload) {
        log.info("刷新广播消息receive:{}", payload);
    }

    @RabbitListener(queues = "fanout.queue1")
    public void directReceive2(String message) {
        log.info("consumer2 received message1 : " + message);
    }

    @RabbitListener(queues = "fanout.queue2")
    public void directReceive3(String message) {
        log.info("consumer3 received message1 : " + message);
    }

}
